"""
函数：insert_img
实现：获取当前运行的路径，拼装截图名称，并生成截图
参数：
    driver: 浏览器对象
    name：截图名
返回值：无
"""
from selenium import webdriver
from time import sleep
from options import options
import os

def insert_img(driver,name):
    #当前目录是tool同级
    dir_name=os.path.dirname(__file__)
    #上一级目录ddt
    up_dir_name=os.path.dirname(dir_name)
    img_name=rf'{up_dir_name}\reports\screenshots\{name}.png'
    driver.get_screenshot_as_file(img_name)
if __name__ == '__main__':
    name = 'baidu'
    url = r'http://172.16.22.105:8080/bsams/front/login.do'
    driver = webdriver.Chrome(options=options)
    driver.get(url)

    insert_img(driver, name)

    driver.quit()